home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue25 / tiptrix / LISTING2.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-08-18  |  754 b   |  20 lines

  1. uses TypInfo;
  2.  
  3. function WhatField(activeCtrl: TWinControl): string;
  4. var
  5.   propInfo: PPropInfo;
  6.   fieldName, nameOfTable: string;
  7. begin
  8.   propInfo := TypInfo.GetPropInfo(activeCtrl. ClassInfo, 'DataField');
  9.   if propInfo <> nil then begin
  10.     fieldName := GetStrProp(activeCtrl, propInfo);
  11.     propInfo := TypInfo.GetPropInfo(activeCtrl.ClassInfo, 'DataSource');
  12.     if propInfo <> nil then
  13.       {note can not return nil since we already checked control has DataField}
  14.       nameOfTable := (TDataSource(GetOrdProp(activeCtrl,
  15.                      propInfo)).DataSet as TTable).TableName;
  16.     Result := Format('%s in %s', [UpperCase(fieldName),
  17.                                   UpperCase(nameOfTable)]);
  18.   end else Result := '';
  19. end;
  20.